Skip to content

b4b: Move the changes to initialize the task decomposition from mpi_scan to main development#3666

Open
ekluzek wants to merge 103 commits into
ESCOMP:b4b-devfrom
ekluzek:decomp_mpi_scan_move_to_b4b
Open

b4b: Move the changes to initialize the task decomposition from mpi_scan to main development#3666
ekluzek wants to merge 103 commits into
ESCOMP:b4b-devfrom
ekluzek:decomp_mpi_scan_move_to_b4b

Conversation

@ekluzek

@ekluzek ekluzek commented Dec 16, 2025

Copy link
Copy Markdown
Contributor

Description of changes

This moves the core code changes to initialize the processor decomposition from the mpi_scan branch in #3469 to b4b-dev. This removes some of the changes for memory checking and additional self testing as well as some of the additional timers that don't look useful now.

I created two previous branches before I created the process in #3665 where I worked out the details to NOT make this have too many commits and be hard to do. I also figured out how to remove merge commits as they need special handling, and usually aren't wanted in a case like this. Another way to do this would be to do this outside of git, which might have been similar length as the final version, but could've missed some important changes.

The actual code changes is that the task/thread decomposition determined at initialization was updated to be based on mpi_scan, rather than using a lot of complex custom code that was a much higher order based on the number of tasks. Methods to calculate the 2D global indicies for a point was added so that it could be displayed on endrun calls. processor_type and clump_type were moved towards an Object-Oriented (OO) programming style, more error checking added, including checking that the decomposion is correct, deallocates some initialization memory that isn't needed.

  • decompMod -- New subroutines: decompmod_allocate_clumps, decompmod_allocate_gindex,,
    calc_ijindices_from_full_global_index
    New methods for processor_type: InitAllocate , calc_global_index_fromij,
    calc_globalxy_indices
    New method for clump_type: Init
    Add new data: nglob_x, nglob_y (global 2D indices)
    Add more error checking
    Add only_gridelll optional argument to get_proc_bounds (needed for calls used before the subgrid levels are set from calling decompInit_glcp)
  • decompModInit -- Remove data no longer used, initialize procinfo data in procinfo%InitAllocate,
    clumps in clumps%Init, use mpi_scan rather than higher order method,
    add error checking, and asserts that decomposition is correct,
    reset clumps data to -1 for non-local processors to show that we don't need it (shows Dimension clumps object by clumps_proc rather than global nclumps #3466 can be done)
    add some timers
  • lnd_set_decomp_and_domain -- add methods to deallocate memory when needed, change timers,
  • Some broad changes: some endrun/shr_sys_abort calls changed to use the file, line format, initialize more pointers to null,

Changes of note for users:

  • On endrun the 2D indices of the gridpoint are written out for endrun calls that send the point
  • There is some checking that the PE decomposition is created correctly will now abort if it's wrong

Changes of note for developers:

  • set_decomp_info in unittestSubGridMod uses more decompMod procedures
  • Limitations of the decompMod testing are given in test_decompMod.pf

Specific notes

Contributors other than yourself, if any: John Dennis

CTSM Issues Fixed (include github issue #):
Fixes #3370
Fixes #3368
Fixes #3672
Some work on #3448
Some work on #3476

Are answers expected to change (and if so in what way)? No (the determination of the PE decomposition is identical as well)

Any User Interface Changes (namelist or namelist defaults changes)? No

Does this create a need to change or add documentation? Did you do so? No No

Changes to testing:

  • endrun unit tests -- more tests for write_pt_context with the new write of the global 2D indices
  • decompMod tests -- add more tests especially for the new calculation of 2D grid indices,
    use the set_decomp_info to allocate the PE decompostion,
    change test size so ni/nj isn't symmetrical to test that size checks are correct
  • unittestSubGridMod -- add optional add_simple_patch argument to unittest_add_column,
    set more decompMod data in set_decomp_info,
    returns after endrun added for unittests
  • many PF unit tests -- call the unittest_subgrid_teardown for tests that setup a PE decomposition

Testing performed, if any: ran standard testing
The mpi_scan testing branch has had all the test lists run for it: aux_clm, ctsm_sci, decomp_init, decomp_init_uhr, and fates

 Conflicts:
	src/cpl/share_esmf/lnd_set_decomp_and_domain.F90
…e destroyed so remove the destroy for the distgrid, and the two meshes, this runs but doesn't seem to lower memory
…e about leaving the distgrid around, and also delete the meshes as it seems to work with this in place
 Conflicts:
	src/main/decompInitMod.F90
 Conflicts:
	src/cpl/share_esmf/lnd_set_decomp_and_domain.F90
…ted error messaging

 Conflicts:
	src/main/decompInitMod.F90
…he subname, create new internal subroutines in decompInit_lnd for allocate, clean, and check errors, move the check errors part to the first thing done

 Conflicts:
	src/main/decompInitMod.F90
…array sizes are set before allocates, initialize some decompMod values to invalid for error checking, add error checking to get_proc_bounds/get_proc_clumps, seperate out allocate for gindex to own allocate method, as it has be be done later after decomp is done, these are all improvements in ESCOMP#3448

 Conflicts:
	src/main/decompInitMod.F90
… add error handling of nsegspc, don't check endCohort in get_proc_bounds and get_clump_bounds as doesn't seem to be set

 Conflicts:
	src/main/decompInitMod.F90
…etup/clean for each DecompInit test, move the decomp_mod_clean to decompMod and use it for the decompInit tests

 Conflicts:
	src/main/decompInitMod.F90
	src/self_tests/TestDecompInit.F90 --- removed
…re to the regular operation

 Conflicts:
	src/main/decompInitMod.F90
…mpi-serial

 Conflicts:
	src/main/decompInitMod.F90
 Conflicts:
	src/main/decompInitMod.F90
…sor_type structure, and start adding a couple methods to help get them set
…for mpiscan and verify it, allocate the new procinfo gi and gj indices, make sure they are set, compiles but fails at run

 Conflicts:
	src/main/decompInitMod.F90
…the call expects all subgrid levels to be set
…ocate for the local task, this works for the serial case

 Conflicts:
	src/main/decompInitMod.F90
… clump_pproc for the setting of ggidx

 Conflicts:
	src/main/decompInitMod.F90
…moved for the final version

 Conflicts:
	src/main/decompInitMod.F90
…s for serial mode

 Conflicts:
	src/main/decompInitMod.F90
…global clumps

 Conflicts:
	src/self_tests/TestDecompInit.F90
… the log that aren't needed anymore

 Conflicts:
	src/main/decompInitMod.F90
…iculty or be slower for PE layouts that aren't a power of 2
@ekluzek ekluzek marked this pull request as ready for review May 10, 2026 20:54
Comment thread src/main/test/abortutils_test/test_abortutils.pf
@ekluzek

ekluzek commented May 10, 2026

Copy link
Copy Markdown
Contributor Author

Running aux_clm on Derecho and Izumi. Will also run decomp_init and uhr_decomp_init before merging in.

@ekluzek ekluzek moved this from In progress - b4b-dev to Stalled (needs review, blocked etc.) in CTSM: Upcoming tags May 10, 2026
@ekluzek

ekluzek commented May 10, 2026

Copy link
Copy Markdown
Contributor Author

A few tests fail for odd grids/PE layouts that I'll need to look into:

ERS_D_Mmpi-serial_Ld5.5x5_amazon.I2000Clm50FatesRs.derecho_gnu.clm-FatesCold (RUN)
FSURDATMODIFYCTSM_D_Mmpi-serial_Ld1.5x5_amazon.I2000Clm50SpRs.derecho_gnu (RUN)
SMS_D_Mmpi-serial_Ld5.5x5_amazon.I2000Clm60Bgc.derecho_gnu.clm-HillslopeC (RUN)
SMS_Ld1_PS.nldas2_rnldas2_mnldas2.I2000Ctsm50NwpSpNldas.derecho_gnu.clm-default--clm-nofireemis (RUN)
SMS_Ld1_PS.nldas2_rnldas2_mnldas2.I2000Ctsm50NwpSpNldasRs.derecho_gnu.clm-default--clm-nofireemis (RUN)
SMS_D_Mmpi-serial_Ld5.5x5_amazon.I2000Clm60FatesCrujraRs.izumi_nag.clm-FatesCold (NLCOMP RUN)
SMS_D_Mmpi-serial_Ld5.5x5_amazon.I2000Clm60FatesRs.izumi_nag.clm-FatesCold (NLCOMP RUN)
The 25 point amazon grid for mpi-serial, and the NLDAS 104k point grid on one node

@ekluzek

ekluzek commented May 11, 2026

Copy link
Copy Markdown
Contributor Author

0.8 for Sprint 31

@samsrabin

Copy link
Copy Markdown
Member

@ekluzek Please ping me again to review once you have those tests working.

Comment thread src/cpl/share_esmf/lnd_set_decomp_and_domain.F90
…, since the ESMF objects are inside a particular if statement
@ekluzek

ekluzek commented May 15, 2026

Copy link
Copy Markdown
Contributor Author

OK, all aux_clm tests are working now. The decomp_init testlists were already working, but I might send other testlists just to make sure there isn't some other strange configuration that has problems.

@samsrabin

@ekluzek

ekluzek commented May 15, 2026

Copy link
Copy Markdown
Contributor Author

fates testlist ran as expected on both Izumi and Derecho. The ctsm_sci test list on Derecho has only three tests left to finish, but outside of those everything ran as expected.

@samsrabin

Copy link
Copy Markdown
Member

@ekluzek I think I'm going to need you to walk me through this. Your PR title and description mainly just talk about moving work from some other git branch to here. What does this PR actually do?

@ekluzek

ekluzek commented May 15, 2026

Copy link
Copy Markdown
Contributor Author

@ekluzek I think I'm going to need you to walk me through this. Your PR title and description mainly just talk about moving work from some other git branch to here. What does this PR actually do?

OK, let me update the PR description to go over what it actually does. And I'll try to lay it out in a way that doesn't require a lot of insider technical knowledge. I'd kind of like to have this in before b4b-dev on next Thursday, so maybe I'll schedule a quick code review for Wednesday. I think I'm up for that, but I also might have to change last minute with what's going on in the family. And if it has to be the next cycle that wouldn't be the worst thing to happen either.

Comment thread src/main/decompInitMod.F90
@ekluzek

ekluzek commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

OK @briandobbins and @samsrabin I've updated the description at the top so it tells more about what the code changes mean. Let me know if anything is unclear or missing and I'll fix it. We'll meet next week to finalize anything left to do, and hopefully it can come in pretty quickly after that.

@ekluzek ekluzek moved this from In Progress to Stalled in LMWG: Sprint Planning Board Jun 24, 2026

@samsrabin samsrabin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ekluzek walked @briandobbins and me through the changes, and it all sounds great! We didn't go through the actual CODE changes, but I don't think it would be helpful for me to do so anyway. Approving.

Comment thread src/main/test/accumul_test/test_accumul.pf Outdated
@github-project-automation github-project-automation Bot moved this from Stalled (needs review, blocked etc.) to In progress - master in CTSM: Upcoming tags Jul 1, 2026
Co-authored-by: Sam Rabin <samrabin@ucar.edu>

@briandobbins briandobbins left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the walkthrough; given the passing tests, and the higher degree of understanding, I'm approving without walking through all the code changes. Glad to have this in, and thanks for the hard work on it!

@samsrabin samsrabin moved this from In progress - master to In progress - b4b-dev in CTSM: Upcoming tags Jul 2, 2026
@ekluzek

ekluzek commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

I met yesterday with @samsrabin and @briandobbins and they approved this coming in. I'll update and rerun the testing again and then bring it in. We did think it's important to run all the testing I did previously, especially the ctsm_sci testlist as that will run the CAM VR grids.

1 similar comment
@ekluzek

ekluzek commented Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

I met yesterday with @samsrabin and @briandobbins and they approved this coming in. I'll update and rerun the testing again and then bring it in. We did think it's important to run all the testing I did previously, especially the ctsm_sci testlist as that will run the CAM VR grids.

@ekluzek

ekluzek commented Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

The aux_clm testing ran as expected. So I'm running these testlist now: ctsm_sci, decomp_init, uhr_decomp_init. If that all goes as expected I'll do the merge.

@ekluzek

ekluzek commented Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

The ctsm_sci testlist ran as expected (with one test still in the queue). The decomp_init test all passed as expected. The uhr_decomp_init test had one test run as expected, one that's in the queue and this one failed:

SMS_Ln1_PL.mpasa3p75_mpasa3p75_mt13.I2000Clm45Sp.derecho_intel.clm-for_testing_fastsetup_bypassrun--clm-mpasa3p75 ( RUN)

It ran out of the hour wallclock time it was given. This is concerning because based on previous timings an hour should have been overly generous. From looking at log files it looks like it failed in datm and likely hung so it didn't die until it reached the wallclock limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

b4b bit-for-bit code health improving internal code structure to make easier to maintain (sustainability) enhancement new capability or improved behavior of existing capability performance idea or PR to improve performance (e.g. throughput, memory)

Projects

Status: In progress - b4b-dev
Status: Stalled

Development

Successfully merging this pull request may close these issues.

4 participants